package controller;

import dao.TicketsMapper;
import entity.a_ticket;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import service.TicketsService;

import javax.annotation.Resource;
import java.util.List;

@Controller
    @RequestMapping("/tickets")
public class TicketsController {
    @Resource
    private TicketsService ticketsService;
    @RequestMapping("/display")
    public String display(){
        return "tickets/trading";
    }
    @RequestMapping("/Chart")
    public String display1(){
        return "tickets/tradingChart";
    }
    @RequestMapping("/Search")
    public String display2(@RequestParam(required = false) String ticket_Name,
                            Model model){
        System.out.println(ticket_Name);
        a_ticket ticket = new a_ticket();
        ticket.setAt_ticket_Name(ticket_Name);
        List<a_ticket> list = this.ticketsService.getAll(ticket);
        System.out.println(list);
        model.addAttribute("ticket_Name",ticket_Name);
        model.addAttribute("list",list);
        return "tickets/tradingSearch";
    }
}
